using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Design;
using System.ComponentModel;
using System.Windows.Forms.Design;

namespace GuavaData
{
    public class GuavaEditor : UITypeEditor
    {
        public GuavaEditor()
        {
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null
                && context.Instance != null
                && provider != null)
            {

                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc == null) return null;

                using (GuavaEditorForm gef = new GuavaEditorForm())
                {
                    gef.BaseDomain = value as GuavaData.Domain.Domain;
                    if (edSvc.ShowDialog(gef) == System.Windows.Forms.DialogResult.OK) return gef.BaseDomain;
                }
            }
            return null;
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }


    }
}
